/**
 * @param {Egg.Application} app - egg application
 */
module.exports = (app) => {
	const { router, controller } = app;
	router.post("/api/login", controller.auth.login);
	router.post("/api/register", controller.user.create);

	router.resources("menu", "/api/menu", controller.menu);

	router.resources("user", "/api/user", controller.user);
	router.post("/api/user/setRole", controller.user.setRole); // 给用户设置角色
	router.get("/api/user/getRole/:id", controller.user.getRole); // 获取用户角色

	router.resources("role", "/api/role", controller.role);
	router.get("/api/role/getPerm/:id", controller.role.getPerm); // 获取角色权限
	router.post("/api/role/setPerm", controller.role.setPerm); // 给角色添加权限

	router.resources("perm", "/api/perm", controller.perm);

	router.get("/api/perm/tree", controller.perm.getPermTree); // 获取权限树
	router.get("/api/allRole", controller.role.getallRole); // 获取所有角色
};
